home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / manageme / tcpdump-.001 / tcpdump-~ / tcpdump-3.0.2-linux / libpcap-0.0.6 / checkioctl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-22  |  2.4 KB  |  85 lines

  1. /*
  2.  * Copyright (c) 1994, 1995
  3.  *    The Regents of the University of California.  All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that: (1) source code distributions
  7.  * retain the above copyright notice and this paragraph in its entirety, (2)
  8.  * distributions including binary code include the above copyright notice and
  9.  * this paragraph in its entirety in the documentation or other materials
  10.  * provided with the distribution, and (3) all advertising materials mentioning
  11.  * features or use of this software display the following acknowledgement:
  12.  * ``This product includes software developed by the University of California,
  13.  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
  14.  * the University nor the names of its contributors may be used to endorse
  15.  * or promote products derived from this software without specific prior
  16.  * written permission.
  17.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  18.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  19.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  20.  */
  21.  
  22. /* @(#) $Header: checkioctl.c,v 1.3+ 95/04/08 03:14:53 leres Exp $ (LBL) */
  23.  
  24. /*
  25.  * checkioctl - check to see if fixincludes has been run
  26.  *
  27.  * The problem we're trying to detect is that we're using gcc but
  28.  * fixincludes hasn't been run. Pre-ansi ioctl macros usually
  29.  * look something like:
  30.  *
  31.  *     #define _IO(x, y)    (IOC_VOID | ('x' << 8) | y)
  32.  *
  33.  * while ansi ioctl macros look like:
  34.  *
  35.  *     #define _IO(x, y)    (IOC_VOID | (x << 8) | y)
  36.  *
  37.  * The difference being that in ansi, you can't quote macro arguments.
  38.  * Notice that if you use the pre-ansi macro with ansi code, the first
  39.  * argument is never expanded; it always comes out as 'x' or whatever.
  40.  * This program detects this.
  41.  */
  42.  
  43. #include <sys/types.h>
  44. #include <sys/time.h>
  45. #ifndef SOLARIS
  46. #include <sys/ioctl.h>
  47. #else
  48. #include <sys/ioccom.h>
  49. #endif
  50.  
  51. #include <stdio.h>
  52. #include <stdlib.h>
  53. #include <string.h>
  54.  
  55. #include "pcap-int.h"
  56.  
  57. #ifdef __GNUC__
  58. int main(int, char **);
  59. #endif
  60.  
  61. int
  62. main(argc, argv)
  63.     int argc;
  64.     char **argv;
  65. {
  66.     register char *prog;
  67.  
  68.     if ((prog = strrchr(argv[0], '/')) != NULL)
  69.         ++prog;
  70.     else
  71.         prog = argv[0];
  72.  
  73. #ifdef __GNUC__
  74.     if (_IO('A', 1) == _IO('B', 1)) {
  75.         fprintf(stderr,
  76.             "%s: You are using gcc and need to run fixincludes!\n",
  77.             prog);
  78.         exit(1);
  79.     }
  80. #else
  81.     printf("%s: You are not using gcc\n", prog);
  82. #endif
  83.     exit(0);
  84. }
  85.